<?php

class GroupControllerRelationController extends Controller
{
	public $defaultAction = 'manageRelation';
	public $layout='menu';
	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'manage' page.
	 */
	public function actionCreate()
		{
			Yii::app()->params['pvt'] = 'groupControllerRelationManage';
			Yii::app()->params['top'] = 'accessTop';
			$model = new GroupControllerRelation();
			$arrGroupList = Group::getList('GROUP-ID');
			
			if(isset($_POST['GroupControllerRelation']))
				{
					$model->attributes = $_POST['GroupControllerRelation'];
					if($model->save())
					{
						Yii::app()->user->setFlash('success','Success :- You have successfully Created!');
						$this->redirect(array('managerelation'));
					}
				}
			$this->render('create',array('model'=>$model,'arrGroupList'=>$arrGroupList));
		}
	/**
	 * Manages all models.
	 * manage all controller relationship
	 */
	public function actionManageRelation()
		{
			Yii::app()->params['pvt'] = 'groupControllerRelationManage';
			Yii::app()->params['top'] = 'accessTop';
			$model=new GroupControllerRelation('search');
			$arrGroupList = Group::getList('GROUP-ID');
			$model->unsetAttributes();  // clear any default values
			if(isset($_GET['GroupControllerRelation']))
				$model->attributes=$_GET['GroupControllerRelation'];
	
			$this->render('managerelation',array(
				'model'=>$model,
			'arrGroupList'=>$arrGroupList
			));
		}
	public function loadModel($id)
				{
					$model = GroupControllerRelation::model()->findByPk($id);
					if($model===null)
						throw new CHttpException(404,'The requested page does not exist.');
					return $model;
				}
	/**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
	public function actionDelete($id)
		{
			if(Yii::app()->request->isPostRequest)
			{
				// we only allow deletion via POST request
				$this->loadModel($id)->delete();
	
				// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
				if(!isset($_GET['ajax']))
					$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('managerelation'));
			}
			else
				throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
		}
	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($id)
		{
			Yii::app()->params['pvt'] = 'groupControllerRelationManage';
			Yii::app()->params['top'] = 'accessTop';
			$model=$this->loadModel($id);
			$arrGroupList = Group::getList('GROUP-ID');
			// Uncomment the following line if AJAX validation is needed
			// $this->performAjaxValidation($model);
	
			if(isset($_POST['GroupControllerRelation']))
			{
				$model->attributes=$_POST['GroupControllerRelation'];
				if($model->save())
				{
					Yii::app()->user->setFlash('success','success :- You have successfully Updated!');
					$this->redirect(array('managerelation'));
				}
			}
	
			$this->render('update',array(
				'model'=>$model,
				'arrGroupList'=>$arrGroupList
			));
		}
}